<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>点哏儿后台管理</title>
    <script src="js/jquery-3.2.1.js"></script>
    <script src="layui/layui.js"></script>
    <script src="layui/lay/modules/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="layui/css/modules/layer/default/layer.css">
</head>
<body>
<div style="width: 40%;margin-top: 10px;">
    <form class="layui-form" action="updateManagerInfo" method="post">
        <!--姓名-->
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="manager_name" required lay-verify="required"
                       value="<#if objectManager.manager_name??>${objectManager.manager_name}</#if>" placeholder="请输入标题"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--手机号-->
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input type="text" name="manager_tel" required lay-verify="phone"
                       value="<#if objectManager.manager_tel??>${objectManager.manager_tel}</#if>" placeholder="请输入标题"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--密码-->
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="manager_password" required lay-verify="pass"
                       value="<#if objectManager.manager_password??>${objectManager.manager_password}</#if>"
                       placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--职务-->
        <div class="layui-form-item">
            <label class="layui-form-label">职务</label>
            <div class="layui-input-block">
                <input type="text" name="manager_postion" required lay-verify="required"
                       value="<#if objectManager.manager_postion??>${objectManager.manager_postion}</#if>"
                       placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--地址-->
        <div class="layui-form-item">
            <label class="layui-form-label">地址</label>
            <div class="layui-input-block">
                <input type="text" name="manager_address" required lay-verify="required"
                       value="<#if objectManager.manager_address??>${objectManager.manager_address}</#if>" value=""
                       placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--性别-->
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <select name="manager_sex" lay-verify="required">
                    <option value="${objectManager.manager_sex}">${objectManager.manager_sex}</option>
                    <#if (objectManager.manager_sex=='男')>
                    <option value="女">女</option>
                    <#else>
                    <option value="男">男</option>
                </#if>
                </select>
            </div>
        </div>
        <!--头像-->
        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <img id="test1" style="border: solid #F0F0F0 1px;" alt="暂无头像" width="80px" height="80px"
                     src="<#if objectManager.manager_photo??>${objectManager.manager_photo}<#else>/img/managerPhoto/managerPhoto.jpg</#if>">
            </div>
        </div>
        <!--确定按钮-->
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button class="layui-btn" lay-submit lay-filter="formDemo">提交修改</button>
        </div>
    </form>
</div>

<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;
        form.verify({
            pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
        });

        //监听提交
        form.on('submit(formDemo)', function (data) {
            $.ajax({
                type: 'POST',
                url: "updateManagerInfo",
                data: data.field,
                success: function (res) {
                    if (res.statusCode == "0") {
                        layer.confirm('修改成功', {
                            btn: ['确定'] //可以无限个按钮

                        }, function (index, layero) {
                            //按钮【按钮一】的回调
                            location.href = "manager_list";
                        });

                    } else {
                        layer.alert(res.message);
                    }
                },
                error: function (res) {
                    layer.alert("发生异常，修改失败！");
                }
            });
            return false;
        });
    });
</script>
<script>
    layui.use('upload', function () {
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            , url: 'opdateManagerPhoto' //上传接口
            , done: function (res) {
                //上传完毕回调
                layer.msg("上传成功！", {icon: 1});
                console.log(res.data.src);
                $("#test1").attr('src', res.data.src.toString());
            }
            , error: function () {
                layer.msg("上传失败！", {icon: 5});
            }
        });
    });
</script>
</body>
</html>